<template>
  <form-model
    ref="editModal"
    :formTitle="$t('modify')+$t('file')"
    :width="608"
    :form="formUploadFile"
    :rules="uploadRules"
    @ok="uploadOk"
  >
    <!-- 预计安装时间 -->
    <a-form-model-item :label="$t('estimatedInstallTime')+'(s)' " prop="installSec">
      <a-input-number
        style="width: 100%"
        v-model="formUploadFile.installSec"
        :placeholder="$t('pleaseInput')+$t('estimatedInstallTime')"
      ></a-input-number>
    </a-form-model-item>
    <!-- 超时时长 -->
    <a-form-model-item :label="$t('timeout')+'(s)' " prop="timeoutSec">
      <a-input-number
        style="width: 100%"
        v-model="formUploadFile.timeoutSec"
        :placeholder="$t('pleaseInput')+$t('timeout')"
      ></a-input-number>
    </a-form-model-item>
    <!-- 文件烧写类型 -->
    <!-- <a-form-model-item :label="$t('file')+$t('sxType')" prop="fileReprogramType">
      <a-select
        v-model="formUploadFile.fileReprogramType"
        showSearch
        :placeholder="$t('pleaseSelect')+$t('file')+$t('sxType')"
        optionFilterProp="children"
        :filterOption="$commonFun.filterOption"
        style="width: 100%"
      >
        <a-select-option
          v-for="(item,index) in dllNameDictCode"
          :key="index"
          :value="item.code"
          :title="item.name"
        >{{ item.name }}</a-select-option>
      </a-select>
    </a-form-model-item> -->
  </form-model>

</template>
<script>
import FormModel from '@/components/SelfModal/FormModel'
import { checkIsRangeInteger } from '@/utils/validate'
export default {
  name: 'UploadVersionFile',
  components: { FormModel },
  data () {
    return {
      formUploadFile: { installSec: undefined, timeoutSec: undefined, fileReprogramType: undefined },
      uploadRules: {
        // eslint-disable-next-line max-len
        installSec: [{ required: true, message: this.$t('pleaseInput') }, { validator: checkIsRangeInteger(1, 2147483647) }],
        // eslint-disable-next-line max-len
        timeoutSec: [{ required: true, message: this.$t('pleaseInput') }, { validator: checkIsRangeInteger(1, 2147483647) }],
        fileReprogramType: [{ required: true, message: this.$t('pleaseSelect') }]
      },
      dllNameDictCode: [],
      disableOriginVersion: true,
      verisonList: [],
      tempSaveIndex: 0
    }
  },
  methods: {
    editFiles (data, record, index) {
      const vm = this
      vm.$api.searchFlushType().then(res => {
        vm.dllNameDictCode = res.data
        vm.formUploadFile.installSec = record.installSec
        vm.formUploadFile.timeoutSec = record.timeoutSec
        vm.formUploadFile.fileReprogramType = record.fileReprogramType
        vm.tempSaveIndex = index
        vm.$refs.editModal.visible = true
      })
    },
    uploadOk () {
      const vm = this
      vm.formUploadFile.tableIndex = vm.tempSaveIndex
      vm.$emit('saveForm', vm.formUploadFile)
      vm.$refs.editModal.visible = false
    }
  }
}
</script>
